package com.yanqu.road.entity.activity.peakseacraft;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.entity.union.UnionBaseInfo;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @Description 海上争霸之南海丝路 跨服 玩家数据
 */
@FieldTypeAnnotation(tableName = "t_c_activity_peak_seacraft_user")
public class PeakSeacraftCrossUserData extends DataObject {
    @FieldTypeAnnotation(desc = "活动id", select = true, update = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "商会分组", select = true, update = true)
    private int unionGroup;
    @FieldTypeAnnotation(desc = "玩家id", update = true)
    private long userId;
    @FieldTypeAnnotation(desc = "区服id")
    private long serverId;
    @FieldTypeAnnotation(desc = "联盟id")
    private String unionId;
    @FieldTypeAnnotation(desc = "职位")
    private int unionPosition;
    @FieldTypeAnnotation(desc = "积分")
    private int score;
    @FieldTypeAnnotation(desc = "本轮突袭次数")
    private int raidAttackTimes;
    @FieldTypeAnnotation(desc = "刷新轮次(刷新 本轮进攻次数、本轮突袭次数 用)")
    private int round;
    @FieldTypeAnnotation(desc = "玩家攻击过的联盟次数 （判断一键挑战用）")
    private int attackNum;
    @FieldTypeAnnotation(desc = "锁定的船员信息 k:阵容类型，v:阵容门客集合")
    private Map<Integer, PeakSeacraftTeamInfo> shipMemberMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "玩家自己的捐献经验")
    private int donateExp;
    @FieldTypeAnnotation(desc = "本轮使用加速道具详情")
    private Map<Integer, PeakSeacraftUseSpeedUpInfo> useSpeedUpInfoMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "每轮积分")
    private Map<Integer, Integer> roundScore = new HashMap<>();

    public PeakSeacraftCrossUserData() {
    }

    public PeakSeacraftCrossUserData(int activityId, int unionGroup, long userId) {
        this.activityId = activityId;
        this.unionGroup = unionGroup;
        this.userId = userId;
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }
    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public long getServerId() {
        return serverId;
    }
    public void setServerId(long serverId) {
        if (this.serverId != serverId) {
            this.serverId = serverId;
            setOp(DataStatus.Update);
        }
    }

    public String getUnionId() {
        return unionId;
    }
    public void setUnionId(String unionId) {
        if (unionId == null){
            return;
        }
        if (this.unionId == null || !this.unionId.equals(unionId)) {
            this.unionId = unionId;
            setOp(DataStatus.Update);
        }
    }

    public int getScore() {
        return score;
    }
    public void setScore(int score) {
        if (this.score != score) {
            this.score = score;
            setOp(DataStatus.Update);
        }
    }

    public int getRaidAttackTimes() {
        return raidAttackTimes;
    }
    public void setRaidAttackTimes(int raidAttackTimes) {
        if (this.raidAttackTimes != raidAttackTimes) {
            this.raidAttackTimes = raidAttackTimes;
            setOp(DataStatus.Update);
        }
    }

    public int getRound() {
        return round;
    }
    public void setRound(int round) {
        if (this.round != round) {
            this.round = round;
            setOp(DataStatus.Update);
        }
    }

    public int getAttackNum() {
        return attackNum;
    }
    public void setAttackNum(int attackNum) {
        if (this.attackNum != attackNum) {
            this.attackNum = attackNum;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, PeakSeacraftTeamInfo> getShipMemberMap() {
        return shipMemberMap;
    }
    public void setShipMemberMap(ConcurrentHashMap<Integer, PeakSeacraftTeamInfo> shipMemberMap) {
        if (null == shipMemberMap){
            return;
        }
        if (this.shipMemberMap == null || !this.shipMemberMap.equals(shipMemberMap)) {
            this.shipMemberMap = shipMemberMap;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, PeakSeacraftUseSpeedUpInfo> getUseSpeedUpInfoMap() {
        return useSpeedUpInfoMap;
    }

    public void setUseSpeedUpInfoMap(ConcurrentHashMap<Integer, PeakSeacraftUseSpeedUpInfo> useSpeedUpInfoMap) {
        if (null == useSpeedUpInfoMap){
            return;
        }
        if (this.useSpeedUpInfoMap == null || !this.useSpeedUpInfoMap.equals(useSpeedUpInfoMap)) {
            this.useSpeedUpInfoMap = useSpeedUpInfoMap;
            setOp(DataStatus.Update);
        }
    }

    public int getDonateExp() {
        return donateExp;
    }

    public void setDonateExp(int donateExp) {
        if (this.donateExp != donateExp){
            this.donateExp = donateExp;
            setUpdateOption();
        }
    }

    public Map<Integer, Integer> getRoundScore() {
        return roundScore;
    }

    public void setRoundScore(Map<Integer, Integer> roundScore) {
        this.roundScore = roundScore;
    }

    public void addRoundScore(int round, int score) {
        int oldScore = roundScore.getOrDefault(round, 0);
        roundScore.put(round, oldScore + score);
        setUpdateOption();
    }

    public int getUnionPosition() {
        return unionPosition;
    }

    public void setUnionPosition(int unionPosition) {
        if(this.unionPosition != unionPosition) {
            this.unionPosition = unionPosition;
            setUpdateOption();
        }
    }

    public int getUnionGroup() {
        return unionGroup;
    }

    public void setUnionGroup(int unionGroup) {
        this.unionGroup = unionGroup;
    }
}
